package homework01;
import static java.lang.System.out;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test {
	public static void main(String[] args) {
		writeFile("F:/IJ/Text02/HomeWork1016/doc/test.txt","Hello World!");
	}
	public static void writeFile(String path,String content) {
		FileInputStream fis = null;
		FileOutputStream fos = null;
		try {
			byte[] words = content.getBytes();
			fos =  new FileOutputStream(path,true);
			fos.write(words);
			fis = new FileInputStream(path);
			int ch;
			while ((ch = fis.read()) != -1) {
				out.print((char) ch);
			}
		} catch (Exception e) {
			e.getStackTrace();
		}finally{
			if(fos != null) {
				try {
					fos.close();
					fis.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
